OpenVINO IR model export - #1238
Conversation
- Resolved conflicts in src/rfdetr/detr.py - Combined OpenVINO and ExecuTorch export features - Updated format documentation to include both openvino and executorch - Updated return type to include .xml (OpenVINO) and .pte (ExecuTorch) - Both formats now use direct conversion (no ONNX intermediate) - Merged upstream changes: ExecuTorch export, dataset improvements, CI updates
- Added [openvino] optional dependency to pyproject.toml - Updated all error messages to use 'pip install "rfdetr[openvino]"' - Updated OpenVINO export documentation with new installation instructions - Consistent with other optional dependencies (onnx, tflite, executorch, tensorrt)
- Update OpenVINO IR description to mention broader hardware support - Mention CPU (x86, ARM), GPU (Intel integrated & discrete), and AI accelerators (Intel NPU) - Make documentation more neutral and less Intel-specific - Simplify installation instructions - Remove redundant advantages section
|
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (3%) is below the target coverage (95%). You can increase the patch coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## develop #1238 +/- ##
=========================================
- Coverage 86% 57% -29%
=========================================
Files 114 116 +2
Lines 14880 14999 +119
=========================================
- Hits 12835 8533 -4302
- Misses 2045 6466 +4421 🚀 New features to boost your workflow:
|
@avbelova could you ls check ^^ 🦝 |
There was a problem hiding this comment.
Pull request overview
Adds a new OpenVINO IR export path to RF-DETR, enabling direct PyTorch → OpenVINO conversion and documenting how to use the exported artifacts.
Changes:
- Added an OpenVINO exporter and a small inference wrapper under
src/rfdetr/export/_openvino/. - Integrated
format="openvino"intoRFDETR.export()and added anopenvinooptional dependency extra. - Updated export documentation to include OpenVINO IR export usage and examples.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rfdetr/export/_openvino/README.md | New OpenVINO export usage guide and inference examples. |
| src/rfdetr/export/_openvino/inference.py | Adds a lightweight OpenVINO IR inference wrapper. |
| src/rfdetr/export/_openvino/exporter.py | Implements direct PyTorch → OpenVINO IR conversion and saving. |
| src/rfdetr/export/_openvino/init.py | Declares the OpenVINO export utilities package. |
| src/rfdetr/detr.py | Extends RFDETR.export() to support format="openvino". |
| pyproject.toml | Adds openvino optional dependency extra. |
| docs/learn/export.md | Documents OpenVINO IR export workflow and examples. |
Comments suppressed due to low confidence (2)
src/rfdetr/export/_openvino/README.md:88
- The inference example loads
output/inference_model.xml, but forRFDETRMediumthe exporter will writeoutput/rfdetr-medium.xmlby default (becausevariant_name=self.size). This example should use the correct filename to avoid a copy/paste FileNotFoundError.
# Load the exported model
model = OpenVINOInference("output/inference_model.xml")
src/rfdetr/export/_openvino/README.md:113
- The
benchmark_appexample usesoutput/inference_model.xml, but the default filename forRFDETRMediumexport isoutput/rfdetr-medium.xml(becausevariant_name=self.size). Update the command so it works as written.
```bash
benchmark_app -m output/inference_model.xml -data_shape [1,3,576,576]
</details>
| if variant_name is not None: | ||
| export_name = f"{variant_name}-backbone" if backbone_only else variant_name | ||
| else: | ||
| export_name = "backbone_model" if backbone_only else "inference_model" |
| # Ensure model is in eval mode and on CPU | ||
| model.eval() | ||
| model = model.cpu() | ||
| input_tensors = input_tensors.cpu() |
| output = self.model(x) | ||
|
|
||
| # Handle backbone-only case (returns tensor directly) | ||
| if not isinstance(output, dict): | ||
| return (output,) |
| # Initialize OpenVINO runtime | ||
| core = ov.Core() | ||
| self.model = core.read_model(model_path) | ||
| self.compiled_model = core.compile_model(self.model, "CPU") |
| This will create two files: | ||
|
|
||
| - `output/inference_model.xml` - The OpenVINO IR model | ||
| - `output/inference_model.bin` - The model weights |
| This produces two files: | ||
|
|
||
| - `output/rfdetr-medium.xml` - The model structure (Intermediate Representation) | ||
| - `output/rfdetr-medium.bin` - The model weights |
| if format == "openvino": | ||
| try: | ||
| from rfdetr.export._openvino.exporter import export_openvino | ||
| except ImportError: | ||
| logger.error( |
- Add path traversal sanitization for variant_name parameter - Call model.export() before OpenVINO conversion to ensure proper export mode - Handle tuple outputs explicitly in ModelWrapper to prevent incorrect nesting - Use AUTO device selection instead of hardcoded CPU for better performance - Update documentation to reflect actual output filenames (rfdetr-medium.xml)
@Borda the corporate CLA is signed between Roboflow and Intel |
Perfect! 🎉 |
What does this PR do?
This PR adds RF-DETR model export to OpenVINO IR (Intermediate Representation).
Type of Change
Testing
Checklist
ref: #1024